/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GUIAgregarPerfil.java
 *
 * Created on Oct 19, 2011, 6:03:50 PM
 */
package GUI.Seguridad;

import BE.BEInterface;
import BE.BEPerfil;
import BL.*;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.ListModel;

/**
 *
 * @author hunter2409
 */
public class GUIAgregarPerfil extends javax.swing.JDialog {
    
    private BLPerfil objGestorPerfil;
    private BEPerfil objPerfil;
    private boolean edicion;
    /** Creates new form GUIAgregarPerfil */
    public GUIAgregarPerfil(java.awt.Frame parent, boolean modal) {
        
        super(parent, modal);
        edicion=false;
        objGestorPerfil= new BLPerfil();
        objGestorPerfil.cargarListaSistema();
        initComponents();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int height = screenSize.height;
        int width = screenSize.width;
        this.setLocation(width/2-this.getWidth()/2, height/2-this.getHeight()/2);
        
    }

    public GUIAgregarPerfil(java.awt.Frame parent, boolean rootPaneCheckingEnabled, BEPerfil aux) {
        
        super(parent,rootPaneCheckingEnabled);
        objGestorPerfil= new BLPerfil();
        objGestorPerfil.cargarListaSistema();
        
        edicion=true;
        objPerfil=aux;
        initComponents();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int height = screenSize.height;
        int width = screenSize.width;
        this.setLocation(width/2-this.getWidth()/2, height/2-this.getHeight()/2);
       
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jInternalFrame1 = new javax.swing.JInternalFrame();
        pnlMantenimientos = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        lstVDMantenimientos = new javax.swing.JList();
        jScrollPane2 = new javax.swing.JScrollPane();
        lstVSMantenimientos = new javax.swing.JList();
        btnAgregarMantenimiento = new javax.swing.JButton();
        btnQuitarMantenimiento = new javax.swing.JButton();
        btnAgregarTodosMantenimiento = new javax.swing.JButton();
        btnQuitarTodosMantenimiento = new javax.swing.JButton();
        pnlDatosPrincipales = new javax.swing.JPanel();
        lbNombre = new javax.swing.JLabel();
        lbDescripcion = new javax.swing.JLabel();
        txtNombre = new javax.swing.JTextField();
        jScrollPane3 = new javax.swing.JScrollPane();
        txtDescripcion = new javax.swing.JTextArea();
        lbEstado = new javax.swing.JLabel();
        cmbEstado = new javax.swing.JComboBox();
        pnlReportes = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        lstVDReportes = new javax.swing.JList();
        jScrollPane5 = new javax.swing.JScrollPane();
        lstVSReportes = new javax.swing.JList();
        btnAgregarReporte = new javax.swing.JButton();
        btnQuitarReporte = new javax.swing.JButton();
        btnAgregarTodosReportes = new javax.swing.JButton();
        btnQuitarTodosReportes = new javax.swing.JButton();
        pnlProcesamiento = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        lstVDProcesamiento = new javax.swing.JList();
        jScrollPane7 = new javax.swing.JScrollPane();
        lstVSProcesamiento = new javax.swing.JList();
        btnAgregarProcesamiento = new javax.swing.JButton();
        btnQuitarProcesamiento = new javax.swing.JButton();
        btnAgregarTodosProcesamiento = new javax.swing.JButton();
        btnQuitarTodosProcesamiento = new javax.swing.JButton();
        pnlSeguridad = new javax.swing.JPanel();
        jScrollPane8 = new javax.swing.JScrollPane();
        lstVDSeguridad = new javax.swing.JList();
        jScrollPane9 = new javax.swing.JScrollPane();
        lstVSSeguridad = new javax.swing.JList();
        btnAgregarSeguridad = new javax.swing.JButton();
        btnQuitarSeguridad = new javax.swing.JButton();
        btnAgregarTodosSeguridad = new javax.swing.JButton();
        btnQuitarTodosSeguridad = new javax.swing.JButton();
        btnGuardar = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();

        jInternalFrame1.setVisible(true);

        javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
        jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
        jInternalFrame1Layout.setHorizontalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jInternalFrame1Layout.setVerticalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Agregar Perfil");
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        pnlMantenimientos.setBorder(javax.swing.BorderFactory.createTitledBorder("Mantenimientos"));

        lstVDMantenimientos.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(lstVDMantenimientos);

        lstVSMantenimientos.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane2.setViewportView(lstVSMantenimientos);

        btnAgregarMantenimiento.setText(">");
        btnAgregarMantenimiento.setMaximumSize(new java.awt.Dimension(30, 30));
        btnAgregarMantenimiento.setMinimumSize(new java.awt.Dimension(30, 30));
        btnAgregarMantenimiento.setPreferredSize(new java.awt.Dimension(30, 30));
        btnAgregarMantenimiento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarMantenimientoActionPerformed(evt);
            }
        });

        btnQuitarMantenimiento.setText("<");
        btnQuitarMantenimiento.setMaximumSize(new java.awt.Dimension(30, 30));
        btnQuitarMantenimiento.setMinimumSize(new java.awt.Dimension(30, 30));
        btnQuitarMantenimiento.setPreferredSize(new java.awt.Dimension(30, 30));
        btnQuitarMantenimiento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuitarMantenimientoActionPerformed(evt);
            }
        });

        btnAgregarTodosMantenimiento.setText("<<");
        btnAgregarTodosMantenimiento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarTodosMantenimientoActionPerformed(evt);
            }
        });

        btnQuitarTodosMantenimiento.setText(">>");
        btnQuitarTodosMantenimiento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuitarTodosMantenimientoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlMantenimientosLayout = new javax.swing.GroupLayout(pnlMantenimientos);
        pnlMantenimientos.setLayout(pnlMantenimientosLayout);
        pnlMantenimientosLayout.setHorizontalGroup(
            pnlMantenimientosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlMantenimientosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlMantenimientosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnAgregarTodosMantenimiento, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
                    .addComponent(btnQuitarMantenimiento, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
                    .addComponent(btnQuitarTodosMantenimiento, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
                    .addComponent(btnAgregarMantenimiento, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        pnlMantenimientosLayout.setVerticalGroup(
            pnlMantenimientosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlMantenimientosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlMantenimientosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, 0, 0, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlMantenimientosLayout.createSequentialGroup()
                        .addComponent(btnAgregarTodosMantenimiento, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnQuitarMantenimiento, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
                        .addComponent(btnAgregarMantenimiento, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnQuitarTodosMantenimiento, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pnlDatosPrincipales.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Perfil"));

        lbNombre.setText("Nombre:");

        lbDescripcion.setText("Descripcion:");

        txtDescripcion.setColumns(20);
        txtDescripcion.setRows(5);
        jScrollPane3.setViewportView(txtDescripcion);

        lbEstado.setText("Estado:");

        cmbEstado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ACTIVO", "INACTIVO" }));
        cmbEstado.setEnabled(false);

        javax.swing.GroupLayout pnlDatosPrincipalesLayout = new javax.swing.GroupLayout(pnlDatosPrincipales);
        pnlDatosPrincipales.setLayout(pnlDatosPrincipalesLayout);
        pnlDatosPrincipalesLayout.setHorizontalGroup(
            pnlDatosPrincipalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosPrincipalesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDatosPrincipalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlDatosPrincipalesLayout.createSequentialGroup()
                        .addGroup(pnlDatosPrincipalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbNombre)
                            .addComponent(lbDescripcion))
                        .addGap(31, 31, 31)
                        .addGroup(pnlDatosPrincipalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 262, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 692, Short.MAX_VALUE)))
                    .addGroup(pnlDatosPrincipalesLayout.createSequentialGroup()
                        .addComponent(lbEstado)
                        .addGap(31, 31, 31)
                        .addComponent(cmbEstado, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        pnlDatosPrincipalesLayout.setVerticalGroup(
            pnlDatosPrincipalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosPrincipalesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDatosPrincipalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbNombre)
                    .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnlDatosPrincipalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbDescripcion)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnlDatosPrincipalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbEstado)
                    .addComponent(cmbEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(86, 86, 86))
        );

        pnlReportes.setBorder(javax.swing.BorderFactory.createTitledBorder("Reportes"));

        lstVDReportes.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane4.setViewportView(lstVDReportes);

        lstVSReportes.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane5.setViewportView(lstVSReportes);

        btnAgregarReporte.setText(">");
        btnAgregarReporte.setMaximumSize(new java.awt.Dimension(30, 30));
        btnAgregarReporte.setMinimumSize(new java.awt.Dimension(30, 30));
        btnAgregarReporte.setPreferredSize(new java.awt.Dimension(30, 30));
        btnAgregarReporte.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarReporteActionPerformed(evt);
            }
        });

        btnQuitarReporte.setText("<");
        btnQuitarReporte.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuitarReporteActionPerformed(evt);
            }
        });

        btnAgregarTodosReportes.setText("<<");
        btnAgregarTodosReportes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarTodosReportesActionPerformed(evt);
            }
        });

        btnQuitarTodosReportes.setText(">>");
        btnQuitarTodosReportes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuitarTodosReportesActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlReportesLayout = new javax.swing.GroupLayout(pnlReportes);
        pnlReportes.setLayout(pnlReportesLayout);
        pnlReportesLayout.setHorizontalGroup(
            pnlReportesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlReportesLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(12, 12, 12)
                .addGroup(pnlReportesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnQuitarTodosReportes, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE)
                    .addComponent(btnAgregarTodosReportes, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE)
                    .addComponent(btnQuitarReporte, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE)
                    .addComponent(btnAgregarReporte, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        pnlReportesLayout.setVerticalGroup(
            pnlReportesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlReportesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlReportesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane4)
                    .addGroup(pnlReportesLayout.createSequentialGroup()
                        .addComponent(btnAgregarTodosReportes, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnQuitarReporte, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
                        .addComponent(btnAgregarReporte, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnQuitarTodosReportes, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane5))
                .addContainerGap())
        );

        pnlProcesamiento.setBorder(javax.swing.BorderFactory.createTitledBorder("Procesamiento"));

        lstVDProcesamiento.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane6.setViewportView(lstVDProcesamiento);

        lstVSProcesamiento.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane7.setViewportView(lstVSProcesamiento);

        btnAgregarProcesamiento.setText(">");
        btnAgregarProcesamiento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarProcesamientoActionPerformed(evt);
            }
        });

        btnQuitarProcesamiento.setText("<");
        btnQuitarProcesamiento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuitarProcesamientoActionPerformed(evt);
            }
        });

        btnAgregarTodosProcesamiento.setText("<<");
        btnAgregarTodosProcesamiento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarTodosProcesamientoActionPerformed(evt);
            }
        });

        btnQuitarTodosProcesamiento.setText(">>");
        btnQuitarTodosProcesamiento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuitarTodosProcesamientoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlProcesamientoLayout = new javax.swing.GroupLayout(pnlProcesamiento);
        pnlProcesamiento.setLayout(pnlProcesamientoLayout);
        pnlProcesamientoLayout.setHorizontalGroup(
            pnlProcesamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlProcesamientoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlProcesamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnQuitarTodosProcesamiento, javax.swing.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
                    .addComponent(btnAgregarProcesamiento, javax.swing.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
                    .addComponent(btnQuitarProcesamiento, javax.swing.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
                    .addComponent(btnAgregarTodosProcesamiento, javax.swing.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE))
                .addGap(12, 12, 12)
                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        pnlProcesamientoLayout.setVerticalGroup(
            pnlProcesamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlProcesamientoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlProcesamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane7, 0, 0, Short.MAX_VALUE)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)
                    .addGroup(pnlProcesamientoLayout.createSequentialGroup()
                        .addComponent(btnAgregarTodosProcesamiento, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnQuitarProcesamiento, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
                        .addComponent(btnAgregarProcesamiento, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnQuitarTodosProcesamiento, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        pnlSeguridad.setBorder(javax.swing.BorderFactory.createTitledBorder("Seguridad"));

        lstVDSeguridad.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane8.setViewportView(lstVDSeguridad);

        lstVSSeguridad.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane9.setViewportView(lstVSSeguridad);

        btnAgregarSeguridad.setText(">");
        btnAgregarSeguridad.setMaximumSize(new java.awt.Dimension(30, 30));
        btnAgregarSeguridad.setMinimumSize(new java.awt.Dimension(30, 30));
        btnAgregarSeguridad.setPreferredSize(new java.awt.Dimension(30, 30));
        btnAgregarSeguridad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarSeguridadActionPerformed(evt);
            }
        });

        btnQuitarSeguridad.setText("<");
        btnQuitarSeguridad.setMaximumSize(new java.awt.Dimension(30, 30));
        btnQuitarSeguridad.setMinimumSize(new java.awt.Dimension(30, 30));
        btnQuitarSeguridad.setPreferredSize(new java.awt.Dimension(30, 30));
        btnQuitarSeguridad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuitarSeguridadActionPerformed(evt);
            }
        });

        btnAgregarTodosSeguridad.setText("<<");
        btnAgregarTodosSeguridad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarTodosSeguridadActionPerformed(evt);
            }
        });

        btnQuitarTodosSeguridad.setText(">>");
        btnQuitarTodosSeguridad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuitarTodosSeguridadActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlSeguridadLayout = new javax.swing.GroupLayout(pnlSeguridad);
        pnlSeguridad.setLayout(pnlSeguridadLayout);
        pnlSeguridadLayout.setHorizontalGroup(
            pnlSeguridadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlSeguridadLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlSeguridadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnQuitarTodosSeguridad, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE)
                    .addComponent(btnAgregarSeguridad, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE)
                    .addComponent(btnQuitarSeguridad, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE)
                    .addComponent(btnAgregarTodosSeguridad, javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        pnlSeguridadLayout.setVerticalGroup(
            pnlSeguridadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlSeguridadLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlSeguridadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane9)
                    .addGroup(pnlSeguridadLayout.createSequentialGroup()
                        .addComponent(btnAgregarTodosSeguridad, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnQuitarSeguridad, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
                        .addComponent(btnAgregarSeguridad, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnQuitarTodosSeguridad, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        btnGuardar.setText("Guardar");
        btnGuardar.setMaximumSize(new java.awt.Dimension(100, 25));
        btnGuardar.setMinimumSize(new java.awt.Dimension(100, 25));
        btnGuardar.setPreferredSize(new java.awt.Dimension(100, 25));
        btnGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardarActionPerformed(evt);
            }
        });

        btnCancelar.setText("Cancelar");
        btnCancelar.setMaximumSize(new java.awt.Dimension(100, 25));
        btnCancelar.setMinimumSize(new java.awt.Dimension(100, 25));
        btnCancelar.setPreferredSize(new java.awt.Dimension(100, 25));
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(pnlDatosPrincipales, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addContainerGap())
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(pnlMantenimientos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(pnlReportes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(pnlProcesamiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(pnlSeguridad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(btnGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlDatosPrincipales, javax.swing.GroupLayout.PREFERRED_SIZE, 212, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(pnlProcesamiento, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pnlMantenimientos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlReportes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pnlSeguridad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(25, 25, 25))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed
// TODO add your handling code here:

    int result=JOptionPane.showConfirmDialog(null,"Desea guardar este perfil?", "Registro del Perfil",    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            //JOptionPane.showMessageDialog(null,"Problema al consultar la base de datos"+e.toString(),"Error",JOptionPane.ERROR_MESSAGE);

    if (result==JOptionPane.YES_OPTION)
    {
        try {
            
            String resultado="";
            if(edicion==true)
            {
                objPerfil.setNombre(this.txtNombre.getText());
                objPerfil.setDescripcion(this.txtDescripcion.getText());
                objPerfil.setEstado(cmbEstado.getSelectedItem().toString());
                objPerfil.setInterfacesMantenimiento(modeloALista(lstVSMantenimientos));
                objPerfil.setInterfacesProcesamiento(modeloALista(lstVSProcesamiento));
                objPerfil.setInterfacesSeguridad(modeloALista(lstVSSeguridad));
                objPerfil.setInterfacesReporte(modeloALista(lstVSReportes));
                
                resultado = objGestorPerfil.actualizar(objPerfil);
            }
            else
            {
                    BEPerfil auxPerfil = new BEPerfil();
                    auxPerfil.setNombre(this.txtNombre.getText());
                    auxPerfil.setDescripcion(this.txtDescripcion.getText());
                    auxPerfil.setEstado("ACTIVO");



                    auxPerfil.setInterfacesMantenimiento(modeloALista(lstVSMantenimientos));
                    auxPerfil.setInterfacesProcesamiento(modeloALista(lstVSProcesamiento));
                    auxPerfil.setInterfacesSeguridad(modeloALista(lstVSSeguridad));
                    auxPerfil.setInterfacesReporte(modeloALista(lstVSReportes));
                    resultado = objGestorPerfil.guardar(auxPerfil);
            }
            JOptionPane.showMessageDialog(null,resultado,"Registro de Perfil",JOptionPane.INFORMATION_MESSAGE);
            this.dispose();
        } catch (SQLException ex) {

            Logger.getLogger(GUIAgregarPerfil.class.getName()).log(Level.SEVERE, null, ex);
            this.dispose();
        }
    }




    
    
    
        
}//GEN-LAST:event_btnGuardarActionPerformed

private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
// TODO add your handling code here:
    
    
    objGestorPerfil.cargarLista(lstVDMantenimientos, objGestorPerfil.getInterfacesMantenimiento());
    objGestorPerfil.cargarLista(lstVDProcesamiento, objGestorPerfil.getInterfacesProcesamiento());
    objGestorPerfil.cargarLista(lstVDReportes, objGestorPerfil.getInterfacesReporte());
    objGestorPerfil.cargarLista(lstVDSeguridad, objGestorPerfil.getInterfacesSeguridad());
    
    if(edicion==false)
    {
        objGestorPerfil.cargarLista(lstVSMantenimientos, null);
        objGestorPerfil.cargarLista(lstVSProcesamiento, null);
        objGestorPerfil.cargarLista(lstVSReportes, null);
        objGestorPerfil.cargarLista(lstVSSeguridad, null);
    }
    else
    {
        modoEdicion(objPerfil);
    }
}//GEN-LAST:event_formWindowOpened

private void btnAgregarMantenimientoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarMantenimientoActionPerformed
    
    moverInterface((String) lstVDMantenimientos.getSelectedValue(),lstVDMantenimientos.getSelectedIndex(),(DefaultListModel) lstVDMantenimientos.getModel(),(DefaultListModel) lstVSMantenimientos.getModel());
}//GEN-LAST:event_btnAgregarMantenimientoActionPerformed

private void btnQuitarMantenimientoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitarMantenimientoActionPerformed
    moverInterface((String) lstVSMantenimientos.getSelectedValue(),lstVSMantenimientos.getSelectedIndex(),(DefaultListModel) lstVSMantenimientos.getModel(),(DefaultListModel) lstVDMantenimientos.getModel());
}//GEN-LAST:event_btnQuitarMantenimientoActionPerformed

private void btnAgregarProcesamientoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarProcesamientoActionPerformed
    moverInterface((String) lstVDProcesamiento.getSelectedValue(),lstVDProcesamiento.getSelectedIndex(),(DefaultListModel) lstVDProcesamiento.getModel(),(DefaultListModel) lstVSProcesamiento.getModel());
}//GEN-LAST:event_btnAgregarProcesamientoActionPerformed

private void btnQuitarProcesamientoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitarProcesamientoActionPerformed
    moverInterface((String) lstVSProcesamiento.getSelectedValue(),lstVSProcesamiento.getSelectedIndex(),(DefaultListModel) lstVSProcesamiento.getModel(),(DefaultListModel) lstVDProcesamiento.getModel());
}//GEN-LAST:event_btnQuitarProcesamientoActionPerformed

private void btnAgregarReporteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarReporteActionPerformed
    moverInterface((String) lstVDReportes.getSelectedValue(),lstVDReportes.getSelectedIndex(),(DefaultListModel) lstVDReportes.getModel(),(DefaultListModel) lstVSReportes.getModel());
}//GEN-LAST:event_btnAgregarReporteActionPerformed

private void btnQuitarReporteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitarReporteActionPerformed
    moverInterface((String) lstVSReportes.getSelectedValue(),lstVSReportes.getSelectedIndex(),(DefaultListModel) lstVSReportes.getModel(),(DefaultListModel) lstVDReportes.getModel());
}//GEN-LAST:event_btnQuitarReporteActionPerformed

private void btnAgregarSeguridadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarSeguridadActionPerformed
    moverInterface((String) lstVDSeguridad.getSelectedValue(),lstVDSeguridad.getSelectedIndex(),(DefaultListModel) lstVDSeguridad.getModel(),(DefaultListModel) lstVSSeguridad.getModel());
}//GEN-LAST:event_btnAgregarSeguridadActionPerformed

private void btnQuitarSeguridadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitarSeguridadActionPerformed
    moverInterface((String) lstVSSeguridad.getSelectedValue(),lstVSSeguridad.getSelectedIndex(),(DefaultListModel) lstVSSeguridad.getModel(),(DefaultListModel) lstVDSeguridad.getModel());
}//GEN-LAST:event_btnQuitarSeguridadActionPerformed

private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
    this.dispose();
}//GEN-LAST:event_btnCancelarActionPerformed

private void btnAgregarTodosMantenimientoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarTodosMantenimientoActionPerformed
    objGestorPerfil.cargarLista(lstVDMantenimientos, objGestorPerfil.getInterfacesMantenimiento());
    objGestorPerfil.cargarLista(lstVSMantenimientos,null);
    // TODO add your handling code here:
}//GEN-LAST:event_btnAgregarTodosMantenimientoActionPerformed

private void btnQuitarTodosMantenimientoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitarTodosMantenimientoActionPerformed
    objGestorPerfil.cargarLista(lstVSMantenimientos, objGestorPerfil.getInterfacesMantenimiento());
    objGestorPerfil.cargarLista(lstVDMantenimientos,null);
    // TODO add your handling code here:
}//GEN-LAST:event_btnQuitarTodosMantenimientoActionPerformed

private void btnAgregarTodosProcesamientoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarTodosProcesamientoActionPerformed
    objGestorPerfil.cargarLista(this.lstVDProcesamiento, objGestorPerfil.getInterfacesProcesamiento());
    objGestorPerfil.cargarLista(this.lstVSProcesamiento,null);
    // TODO add your handling code here:
}//GEN-LAST:event_btnAgregarTodosProcesamientoActionPerformed

private void btnQuitarTodosProcesamientoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitarTodosProcesamientoActionPerformed
    objGestorPerfil.cargarLista(this.lstVSProcesamiento, objGestorPerfil.getInterfacesProcesamiento());
    objGestorPerfil.cargarLista(this.lstVDProcesamiento,null);
    // TODO add your handling code here:
}//GEN-LAST:event_btnQuitarTodosProcesamientoActionPerformed

private void btnAgregarTodosReportesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarTodosReportesActionPerformed
    objGestorPerfil.cargarLista(this.lstVDReportes, objGestorPerfil.getInterfacesReporte());
    objGestorPerfil.cargarLista(this.lstVSReportes,null);
       
    // TODO add your handling code here:
}//GEN-LAST:event_btnAgregarTodosReportesActionPerformed

private void btnQuitarTodosReportesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitarTodosReportesActionPerformed
    objGestorPerfil.cargarLista(this.lstVSReportes, objGestorPerfil.getInterfacesReporte());
    objGestorPerfil.cargarLista(this.lstVDReportes,null);
    // TODO add your handling code here:
}//GEN-LAST:event_btnQuitarTodosReportesActionPerformed

private void btnAgregarTodosSeguridadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarTodosSeguridadActionPerformed
    objGestorPerfil.cargarLista(this.lstVDSeguridad, objGestorPerfil.getInterfacesSeguridad());
    objGestorPerfil.cargarLista(this.lstVSSeguridad,null);
    // TODO add your handling code here:
}//GEN-LAST:event_btnAgregarTodosSeguridadActionPerformed

private void btnQuitarTodosSeguridadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitarTodosSeguridadActionPerformed
    objGestorPerfil.cargarLista(this.lstVSSeguridad, objGestorPerfil.getInterfacesSeguridad());
    objGestorPerfil.cargarLista(this.lstVDSeguridad,null);
    // TODO add your handling code here:
}//GEN-LAST:event_btnQuitarTodosSeguridadActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(GUIAgregarPerfil.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(GUIAgregarPerfil.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(GUIAgregarPerfil.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GUIAgregarPerfil.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                GUIAgregarPerfil dialog = new GUIAgregarPerfil(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAgregarMantenimiento;
    private javax.swing.JButton btnAgregarProcesamiento;
    private javax.swing.JButton btnAgregarReporte;
    private javax.swing.JButton btnAgregarSeguridad;
    private javax.swing.JButton btnAgregarTodosMantenimiento;
    private javax.swing.JButton btnAgregarTodosProcesamiento;
    private javax.swing.JButton btnAgregarTodosReportes;
    private javax.swing.JButton btnAgregarTodosSeguridad;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnGuardar;
    private javax.swing.JButton btnQuitarMantenimiento;
    private javax.swing.JButton btnQuitarProcesamiento;
    private javax.swing.JButton btnQuitarReporte;
    private javax.swing.JButton btnQuitarSeguridad;
    private javax.swing.JButton btnQuitarTodosMantenimiento;
    private javax.swing.JButton btnQuitarTodosProcesamiento;
    private javax.swing.JButton btnQuitarTodosReportes;
    private javax.swing.JButton btnQuitarTodosSeguridad;
    private javax.swing.JComboBox cmbEstado;
    private javax.swing.JInternalFrame jInternalFrame1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JLabel lbDescripcion;
    private javax.swing.JLabel lbEstado;
    private javax.swing.JLabel lbNombre;
    public javax.swing.JList lstVDMantenimientos;
    private javax.swing.JList lstVDProcesamiento;
    private javax.swing.JList lstVDReportes;
    private javax.swing.JList lstVDSeguridad;
    private javax.swing.JList lstVSMantenimientos;
    private javax.swing.JList lstVSProcesamiento;
    private javax.swing.JList lstVSReportes;
    private javax.swing.JList lstVSSeguridad;
    private javax.swing.JPanel pnlDatosPrincipales;
    private javax.swing.JPanel pnlMantenimientos;
    private javax.swing.JPanel pnlProcesamiento;
    private javax.swing.JPanel pnlReportes;
    private javax.swing.JPanel pnlSeguridad;
    private javax.swing.JTextArea txtDescripcion;
    private javax.swing.JTextField txtNombre;
    // End of variables declaration//GEN-END:variables

    private void moverInterface(String ventanaSeleccionada, int indiceSeleccionado, DefaultListModel listaFuente, DefaultListModel ListaDestino) {
       
        if (indiceSeleccionado!=-1)    
        {
            listaFuente.remove(indiceSeleccionado);
            ListaDestino.addElement(ventanaSeleccionada);
        }
    
    }

    private ArrayList<BEInterface> modeloALista(JList lista) {
        ArrayList<BEInterface> aux= new ArrayList<BEInterface>();
        
        for ( int i=0 ;i< lista.getModel().getSize();i++)
        {
            //lista.getModel().getElementAt(i).toString()
            aux.add(objGestorPerfil.buscarNombreInterface(lista.getModel().getElementAt(i).toString()));
        }
        
        return aux;
    }

    private void modoEdicion(BEPerfil aux) {
        
        this.setTitle("Editar Perfil - Perfil : "+aux.getNombre());
        
//        System.out.println(aux.getInterfacesMantenimiento().size());
//        System.out.println(aux.getInterfacesProcesamiento().size());
//        System.out.println(aux.getInterfacesReporte().size());
//        System.out.println(aux.getInterfacesSeguridad().size());
        
        objGestorPerfil.cargarLista(lstVSMantenimientos, aux.getInterfacesMantenimiento());
        objGestorPerfil.cargarLista(lstVSProcesamiento, aux.getInterfacesProcesamiento());
        objGestorPerfil.cargarLista(lstVSReportes, aux.getInterfacesReporte());
        objGestorPerfil.cargarLista(lstVSSeguridad, aux.getInterfacesSeguridad());
        
        eliminarRepeticionesLista(lstVDMantenimientos,aux.getInterfacesMantenimiento());
        eliminarRepeticionesLista(lstVDProcesamiento,aux.getInterfacesProcesamiento());
        eliminarRepeticionesLista(lstVDReportes,aux.getInterfacesReporte());
        eliminarRepeticionesLista(lstVDSeguridad,aux.getInterfacesSeguridad());
        
        txtNombre.setText(aux.getNombre());
        txtDescripcion.setText(aux.getDescripcion());
        cmbEstado.setEnabled(true);
        
        if(aux.getEstado().equals("ACTIVO")) cmbEstado.setSelectedIndex(0);
        if(aux.getEstado().equals("INACTIVO")) cmbEstado.setSelectedIndex(1);
        
    }

    private void eliminarRepeticionesLista(JList lista, ArrayList<BEInterface> interfaces) {
       
        ArrayList<BEInterface> aux = modeloALista(lista);
        //System.out.println("Se comienza a filtrar la lista...");
        for(BEInterface inter:interfaces)
        {
            int i=bucarInterface(aux,inter);
            //System.out.println("Se encontro en la pos: " + i);
            if (i!=-1)
            {
                //System.out.println("Se elimino de la lista!");
                aux.remove(i);
            }
        }
        
        objGestorPerfil.cargarLista(lista, aux);
        
    }

    private int bucarInterface(ArrayList<BEInterface> aux, BEInterface inter) {
        
        for(int i=0;i<aux.size();i++)
        {
//            System.out.println("Se comparo: "+aux.get(i).getNombre()+" con: "+inter.getNombre());
            if (aux.get(i).getNombre().equals(inter.getNombre())) return i;
        }
        
        return -1;
        
    }

    private void quitarElementoLista(JList lista, int i) {
        
        DefaultListModel lst = new DefaultListModel();
        
        
        
    }
    
    

    
}
